package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.Shop;

/**
 * QShop is a ORMLite query type for Shop
 * @see Shop
 */
public class QShop extends QEntityBase<Shop> {

    public static final QShop $ = new QShop("SHOP");

    public final Column sn = field("sn").columnName("SN").varchar(16).notNull().build();

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column tel = field("tel").columnName("TEL").varchar(16).build();

    public final Column address = field("address").columnName("ADDRESS").varchar(64).build();

    public final Column brandId = field("brandId").columnName("BRAND_ID").varchar(22).build();

    public class Indexs {

        public final Index constraintIndex2 = index("CONSTRAINT_INDEX_2").unique().column(sn).build();

        public final Index constraintIndex26 = index("CONSTRAINT_INDEX_26").column(brandId).build();

        public final Index primaryKey2 = index("PRIMARY_KEY_2").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint26d = foreignKey(brandId, "BRAND", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShop(String tableName) {
        super(Shop.class, tableName);
    }

    @Override
    public Shop newInstance() {
        return new Shop();
    }

    @Override
    public Object getFieldValue(Shop instance, String fieldName) {
        switch (fieldName) {
            case "sn":
                return instance.getSn();
            case "name":
                return instance.getName();
            case "tel":
                return instance.getTel();
            case "address":
                return instance.getAddress();
            case "brandId":
                return instance.getBrandId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(Shop instance, String fieldName, Object value) {
        switch (fieldName) {
            case "sn":
                instance.setSn((java.lang.String) value);
                break;
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "tel":
                instance.setTel((java.lang.String) value);
                break;
            case "address":
                instance.setAddress((java.lang.String) value);
                break;
            case "brandId":
                instance.setBrandId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

